package com.ideaplugin.datamanager.table.data.simple.controller;

import com.ideaplugin.datamanager.model.common.ListResult;
import com.ideaplugin.datamanager.model.common.PageRequest;
import com.ideaplugin.datamanager.model.common.PageResult;
import com.ideaplugin.datamanager.model.common.PlainResult;
import com.ideaplugin.datamanager.model.request.DeleteUserTableDataParam;
import com.ideaplugin.datamanager.model.request.SaveUserTableDataParam;
import com.ideaplugin.datamanager.model.request.UserTableDataParam;
import com.ideaplugin.datamanager.model.response.PageUserTableDataVo;
import com.ideaplugin.datamanager.model.response.UserTableDataVo;
import com.ideaplugin.datamanager.table.data.simple.service.SimpleUserTableDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * @author zhaojingbo
 * @since 2023-06-07
 */
@RestController
@RequestMapping("/simpleUserTableData")
public class SimpleUserTableDataController {

    @Autowired
    private SimpleUserTableDataService simpleUserTableDataService;


    @PostMapping("/pageUserTableData")
    public PageResult<PageUserTableDataVo> pageUserTableData(@RequestBody @Valid PageRequest<UserTableDataParam> param) {
        return simpleUserTableDataService.pageUserTableData(param);
    }


    @PostMapping("/saveUserTableData")
    public PlainResult<Boolean> saveUserTableData(@RequestBody @Valid SaveUserTableDataParam param) {
        return new PlainResult<>(simpleUserTableDataService.saveUserTableData(param));
    }

    @PostMapping("/queryAggregate")
    public ListResult<UserTableDataVo> queryAggregate(@RequestBody @Valid UserTableDataParam param) {
        return new ListResult<>(simpleUserTableDataService.queryAggregate(param));
    }

    @PostMapping("/deleteUserTableData")
    public PlainResult<Boolean> deleteUserTableData(@RequestBody @Valid DeleteUserTableDataParam param) {
        return new PlainResult<>(simpleUserTableDataService.deleteUserTableData(param));
    }

}
